/** \file    throw_ctrl_signal.h
  * \brief   Gives opportunity for console application to react on CTRL events (CTRL+C, Shut down, ...).
  * \date    2002
  * \author  Fedor Chelnokov
  * \version $Header: /home/cscom1r4/cvsroot/cs/include/mswin/throw_ctrl_signal.h,v 1.1 2004/01/23 21:29:34 cscom1r4 Exp $
  */

#ifndef _throw_ctrl_signal_h_
#define _throw_ctrl_signal_h_

#include "new_exception.h"

namespace mswin {

EXCEPTION(ctrl_signal_base, "CTRL event happened")

class ctrl_signal: public ctrl_signal_base {
public:
	ctrl_signal() : _type(~0) {}
	~ctrl_signal() throw() {}
	ctrl_signal(const char *altMsg) : _type(~0), ctrl_signal_base(altMsg) {}
	ctrl_signal(const std::string &altMsg) : _type(~0), ctrl_signal_base(altMsg) {}
	ctrl_signal(unsigned type);

	unsigned type() const
		{ return _type; }

private:
	unsigned _type; ///< of signal
};

///during existence of this class objects all CTRL signals will be captured and 
///thrown as ctrl_signal exception from check() method
class catcher_ctrl_signal {
public:
	catcher_ctrl_signal();
	~catcher_ctrl_signal();
	void check();
};

}

#endif //_throw_ctrl_signal_h_
